from django.db import models
from db.base import BaseModel
# Create your models here.


class WxOfficalAccount(BaseModel):
    spider_level = (
        (0,"很低"),
        (1,"低"),
        (2,"中"),
        (3,"高"),
        (4,"很高"),
    )
    user_for_choice = (
        (0,"官网"),
        (1,"51客"),
        (2,"都是"),
    )
    kyk_org_id = models.CharField(max_length=64, verbose_name="官网对应机构id", null=True)
    fake_id = models.CharField(max_length=32, verbose_name="微信的内部id", null=True,unique=True)
    article_type = models.CharField(max_length=32, verbose_name="微信公众号的类型", default="财经")
    user_for = models.SmallIntegerField(choices=user_for_choice,verbose_name="用在什么地方",null=False,default=1)
    logo_img_id = models.CharField(max_length=32, verbose_name="微信的头像id", null=True)
    spider_priority = models.SmallIntegerField(verbose_name="爬取优先级别5,4,3,2,1", default=1, null=False,choices=spider_level)
    wechat_code = models.CharField(max_length=32, verbose_name="微信公众号的账号名", null=True)
    org_name = models.CharField(max_length=32, verbose_name="微信公众号名字", null=False)
    state = models.IntegerField(default=0, verbose_name="是否可以抓取，0 可以抓取 1 不可以抓取")
    is_spider = models.BooleanField(default=True, verbose_name="是否已经爬完，默认是")
    logo_url = models.CharField(max_length=255, verbose_name="微信公众号的logourl", null=True)
    org_desc = models.CharField(max_length=255, verbose_name="微信公众号的描述", default="这家伙很懒，什么都没留下")
    spider_from = models.CharField(max_length=32, verbose_name="来源", default="公众号",null=True)
    spider_time = models.DateTimeField(auto_now=True,verbose_name="抓取时间")
    def __str__(self):
        return self.org_name

    class Meta:
        db_table = 'spider_org'
        verbose_name = '公众号列表'
        verbose_name_plural = verbose_name


class OrgTyWxOfficalModelType(BaseModel):
    type_name = models.CharField(max_length=16, verbose_name="标签类型")
    org_id = models.ForeignKey('WxOfficalAccount', verbose_name="关联机构类型的外键")  # 多个文章对应一个 公众号

    class Meta:
        db_table = 'spider_org_type'
        verbose_name = '公众号类型列表'
        verbose_name_plural = verbose_name